<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8"/>
	<link href="css/bootstrap.min.css" rel="stylesheet">
	<link href="css/bootstrap-theme.min.css" rel="stylesheet">
	<link href="css/ds.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
      <div class="container-fluid">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">灰色模型GM(1,1)</a>
        </div>
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
	      <ul class="nav navbar-nav">
	        <li class="active"><a href="#">自定义计算</a></li>
	        </ul>
	     </div>
      </div>
    </nav>
    <div class="container-fluid">
      <div class="row">
        <div class="col-sm-12 col-md-12 main">
          <h1 class="page-header" >往年<span id="section"></span>数据</h1>
          <input id="sample" type="text" class="form-control" placeholder="输入一系列逗号分隔数据" value="1,2,3"/>
          <div>	
          	<h1 class="page-header" >预测数据</h1>
          	<form>
          		<div>
          			<label>我要预测未来<input class="form-control" id="next" value="1"/>年的数据</label>
          		</div>
          		<div>
          			<a class="btn btn-primary" id="prediction-btn">开始预测<i class="glyphicon glyphicon-signal"></i></a>
          		</div>
          	</form>
          	<div class="table-responsive">
	            <table class="table table-striped">
	              <thead>
	                <tr>
	                  <th>预测数值</th>
	                </tr>
	              </thead>
	              <tbody id="predict-data">
	                <tr></tr>
	              </tbody>
	            </table>
	          </div>
	          <div id="chart" style="width:100%;height: 400px;"></div>
	       </div>
        </div>
      </div>
    </div>
    <script src="js/jquery-1.11.1.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
  	<script src="js/data.js" charset="UTF-8"></script>
	<script>
	
	$(function(){
		
		$('#prediction-btn').click(function(){
			
			var param = {next : $('#next').val(), sample : $('#sample').val()};
				
			$.get('predictBatch', param, 'json').success(function(resp){
				
				$('#predict-data').empty();
				
				for(var m in resp){
					
					var e = Number.parseFloat(resp[m]).toFixed(2);
				
					$('#predict-data').append('<tr><td>'+e+'</td></tr>');
				}
			});
		});
	});
	</script>
</body>
</html>